package com.kongmou.webSocket.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;

@Configuration
@EnableWebSocketMessageBroker//启用STOMP传输代理消息
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer{
	
	@Override
	public void registerStompEndpoints(StompEndpointRegistry registry) {
		//注册一个STOPM节点（endpoint）并指定URl和使用SockjS协议
		registry.addEndpoint("/endpointWisely").withSockJS();
		registry.addEndpoint("/endpointChat").withSockJS();
		
	}
	
	
	@Override
	public void configureMessageBroker(MessageBrokerRegistry registry) {
		//广播式配置一个/topic和/queue消息代理
		registry.enableSimpleBroker("/queue","/topic");
	}

}
